home *** CD-ROM | disk | FTP | other *** search
/ Greenhouse Effect Detection Expriment / NASA Greenhouse Effect Detection Expriment 1992 - Disc 2.iso / software / dos / cdf22pc / src / tools / c_util.c next >
Encoding:
C/C++ Source or Header  |  1992-02-27  |  1.4 KB  |  78 lines

  1. /******************************************************************************
  2. *
  3. *  NSSDC/CDF                Utility routines in CDF toolbox.
  4. *
  5. *  Version 2.0, 27-Feb-92, ST Systems (STX)
  6. *
  7. *  Modification history:
  8. *
  9. *   V1.0  24-Jan-91, D Grogan/H Leckner       Original version (for CDF V2.0).
  10. *   V1.1  28-Jun-91, J Love           TRUE/FALSE.
  11. *   V2.0  27-Feb-92, J Love           Modified for IBM-PC port.  CDF V2.2.
  12. *             H Leckner
  13. *
  14. ******************************************************************************/
  15.  
  16. #include <stdlib.h>
  17. #include <stdio.h>
  18.  
  19. #include "cdfdist.h"
  20.  
  21. /*
  22. C_UTIL.c
  23.  
  24. This is a collection of utility routines used in the CDF tool box.
  25.  
  26. */
  27.  
  28. void set_pointer ( ptr_out, ptr_in )
  29.  
  30.     long int    *ptr_out;
  31.     long int    ptr_in;
  32. {
  33.  
  34.     *ptr_out = ptr_in;
  35.  
  36. }
  37.  
  38. void left_justify (field, len)
  39.     char        field[];
  40.     int        len;
  41. {
  42.     long int    i;
  43.     long int    index;
  44.     long int    done;
  45.     char        *temp;
  46.  
  47.     temp = (char *) malloc(len);
  48.  
  49. /* Blank out temporary hold area */
  50.  
  51.     for (i = 0; i < len; i++)
  52.         temp[i] = ' ';
  53.  
  54.  
  55.         done = FALSE;
  56.         for (index = 0; done != TRUE && index <= len; index++)
  57.  
  58.             {
  59. /* Look for a non-blank character */
  60.  
  61.             if(field[index] != ' ')
  62.                 {
  63. /* Left Justify by copying from the non-blank character to the end of field */
  64.  
  65.                 strncpy(temp,field+index,len-index);
  66.                 for (i = 0; i < len; i++)
  67.                     field[i] = ' ';
  68.  
  69. /* Now copy from the temporary field back to the permanent field */
  70.  
  71.                 strncpy(field, temp, len);
  72.                 done = TRUE;
  73.                 }
  74.             }
  75.     free(temp);
  76.  
  77. }  /* end left_justify */
  78.